﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Runtime.InteropServices.JavaScript.JSType;

namespace LeetCode100Hot.笔试.白日梦
{
    internal class 白日梦
    {

        static void Main白日梦(string[] args)
        {
            int[] array = { 1, 2, 3, 4, 5 };
            var query = from num in array where num > 2 select num * num;
            foreach (var num in query)
                Console.Write(num + " ");

            GameObject gameObject = new GameObject();
            Btn btn = new Btn();
            btn.ClickBtn += gameObject.ChangeColor;

            btn.Click();

        }
    }


    public class Btn
    {
        //创建一个事件
        public event Action<string> ClickBtn;

        public void Click()//触发委托
        {
            Console.WriteLine("Button clicked!");
            ClickBtn?.Invoke("123"); //这个时候传值
            //这个上面托管的事件全部触发
        }


    }
    public class GameObject
    {

        public ConsoleColor color;
        public GameObject() { 
        
        color=ConsoleColor.White;
        }
        public void ChangeColor(string tip) {
        
        color = ConsoleColor.Red;
            Console.WriteLine("GameObject变色");
            Console.WriteLine(tip);
        }


    }







}
